<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="./css/Register.css">
<script src="JS/jquery-1.11.3.min.js" type="text/javascript"></script>
</head>

<script type="text/javascript">
function login(){
		$.ajax({
	        url:"${pageContext.request.contextPath}/LoginServlet",
	        async:false,
	        type:"post",
	        data:{'username':$("#username").val(),'password':$("#password").val()},
	        dataType:"json",
	        success:function(d){
	        	if(d.msg==1){
	        		alert("账号或密码错误，请检查")
	        		window.location.reload();
	        	}else{
	        		//我添加了这个
	        		if($("#checkbox").is(":checked")){
	        			window.location.href = "${pageContext.request.contextPath}/ApplicationServlet";
	        		}else{
		        		window.location.href = "${pageContext.request.contextPath}/GetTypeServlet";        		
	        		}
	        	}
	        	
	        }
	    });//ajax over
	
}//login function over
</script>
<body>
<div class="reg_back">
        <div class="reg_left">
            <p>用户登陆</p>
            <p>USER LOGIN</p>
        </div>
        <div class="reg_center">
            <div class="reg_form">
<!--             我的删除掉了form -->
                    <table>
                        <tr>
                            <td class="td_left"><label for="username">用户名</label></td>
                            <td class="td_right"><input type="text" name="username" placeholder="请输入用户名"
                                                        id="username"></td>
                        </tr>
                        <tr>
                            <td class="td_left"><label for="password">密码</label></td>
                            <td class="td_right">
                          		<input type="password" name="password" placeholder="请输入密码" id="password">
                            </td>
                        </tr>
                        
                        <tr>
                       	<tr>
	                       	<td colspan="3" align="center">管理员<input type = "checkbox" id = "checkbox"></td>
                        </tr>
                        	<!-- 我将submit改为button -->
                            <td colspan="2" align="center">
	                            <a onclick="login()"  href="#"class="">
	                            	<input type="button" value="登陆" id="btn_sub">
	                            </a>
                            </td>
                            <td colspan="1" align="center"><a href = "Index.jsp"><input type = "button" value = "返回" id = "return"/></a></td>
                        </tr>
                    </table>
            </div>
        </div>
        <div class="reg_right">
            <p>还没有账号<a href="register2.jsp">立即注册</a></p>
        </div>
    </div>
</body>
</html>